package com.qf.android.huihui.adapter.information;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.qf.android.huihui.R;
import com.qf.android.huihui.bean.dbbean.DBSearchBean;

import java.util.List;

/**
 * Created by lx on 2017/1/12.
 */

public class DbSearchAdapter extends BaseAdapter {
    private List<DBSearchBean> list;
    private Context context;

    public DbSearchAdapter(List<DBSearchBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder=null;
        if(view==null){
            view= LayoutInflater.from(context).inflate(R.layout.listview_search_item,viewGroup,false);
            holder=new ViewHolder();
            holder.tv= (TextView) view.findViewById(R.id.list_search_tv);
            view.setTag(holder);
        }
        else
        holder= (ViewHolder) view.getTag();
        holder.tv.setText(list.get(i).getName());
        return view;
    }

    class ViewHolder{
        private TextView tv;
    }
}
